# Base image for building the application with Gradle and JDK 17
FROM gradle:8.10.2-jdk17 AS build

# Set the working directory
WORKDIR /app

# Copy the Gradle wrapper files if using the wrapper
COPY gradlew gradlew
#COPY gradle gradle

# Copy other build configuration files
COPY build.gradle settings.gradle ./

# Copy the source code for all modules
COPY conf ./conf
COPY src ./src

# Build the application (skip tests for quicker builds)
#RUN gradle bootjar --no-daemon

# Use a minimal JRE for the runtime
FROM openjdk:17-jdk-slim AS runtime

# Set the working directory for the runtime image
WORKDIR /app

# Copy the built JAR file(s) from the build stage
# Assuming module-c produces an executable JAR
#COPY --from=build /app/engine/build/libs/*.jar ./app.jar
#COPY --from=build /app/build/libs/*.jar ./
# Copy the configuration files to the runtime image
#COPY --from=build /app/conf ./conf
COPY build/libs/belf-console-1.0.jar ./

# Expose the desired application port
EXPOSE 8080

# Command to run the application
CMD ["java", "-jar", "belf-console-1.0.jar"]
#CMD ["java", "-cp", "/app/conf:/app/*", "belf.migrate.engine.BelfEngine"]